/* LocalFile - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

public class LocalFile {
	public long currentOffset;
	public long length;
	public File baseFile;
	public RandomAccessFile randomAccessFile;

	public void close() throws IOException {
		randomAccessFile.close();
		randomAccessFile = null;
	}

	public File getBaseFile() {
		return baseFile;
	}

	public void seek(long l) throws IOException {
		randomAccessFile.seek(l);
		currentOffset = l;
	}

	public int read(byte[] dest, int len, int offset) throws IOException {
		int i_2_ = randomAccessFile.read(dest, offset, len);
		if (i_2_ > 0)
			currentOffset += (long) i_2_;
		return i_2_;
	}

	public LocalFile(File file, String string, long l) throws IOException {
		if (l == -1L)
			l = 9223372036854775807L;
		if (l <= file.length())
			file.delete();
		randomAccessFile = new RandomAccessFile(file, string);
		currentOffset = 0L;
		baseFile = file;
		length = l;
	}

	public long length() throws IOException {
		return randomAccessFile.length();
	}

	public void write(int len, int offset, byte[] bytes) throws IOException {
		if (length < (long) len + currentOffset) {
			randomAccessFile.seek(length - -1L);
			randomAccessFile.write(1);
			throw new EOFException();
		}
		randomAccessFile.write(bytes, offset, len);
		currentOffset += (long) len;
	}
}
